// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0

component MyLayout inherits HorizontalLayout {
    Rectangle {
        width: 20phx;
        background: red;
    }
    @children
    Rectangle {
        width: 10phx;
        background: red;
    }
}

component MyLayout2 inherits MyLayout {
    Rectangle {
        width: 2phx;
        background: orange;
    }
    @children
    Rectangle {
        width: 1phx;
        background: orange;
    }
}

component MyLayout3 inherits MyLayout {
    Rectangle {
        width: 2phx;
        background: green;
    }
    Rectangle {
        width: 1phx;
        background: green;
    }
}



export component TestCase inherits Window {
    width: 300phx;
    height: 200phx;

    VerticalLayout {

        MyLayout {
            rect1 := Rectangle {
                background: black;
            }
        }
        MyLayout2 {
            rect2 := Rectangle {
                background: black;
            }
        }
        MyLayout3 {
            rect3 := Rectangle {
                background: black;
            }
        }

    }

    out property <bool> rect1_pos_ok: rect1.x == 20phx && rect1.width == 300phx - 30phx;
    out property <bool> rect2_pos_ok: rect2.x == 22phx && rect2.width == 300phx - 33phx;
    out property <bool> rect3_pos_ok: rect3.x == 23phx && rect3.width == 300phx - 33phx;
    out property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
```


```rust
let instance = TestCase::new().unwrap();
assert!(instance.get_test());
```
*/
